#!/bin/bash

#获取当前脚本文件的路径
shellPath=$(dirname $(readlink -f $0))

jarPath=$shellPath"/xxx.jar"
logDirPath=$shellPath"/log"
logPath=$logDirPath"/xxx.out"
pidFile=$shellPath"/process.pid"

if ! [ -e $jarPath ]; then
echo "unable to find jar file $jarPath"
exit
fi

if [ -e $pidFile ] ; then
pid=`cat $pidFile`
pName=$(ps -ef | grep $pid| grep -v grep | awk 'NR==1 {print $NF}')
if [ "$jarPath" = "$pName" ]; then
echo "The program is running, please close it before starting it"
exit
fi
fi

! [ -d $logDirPath ] && `mkdir -p $logDirPath`

nohup java -Xms1024m -Xmx1024m -jar $jarPath > $logPath 2>&1 &
pid=$!
echo $pid > process.pid
echo "$jarPath start up Success! pid is $pid"
#启动关闭jar包参数
